Add a range or query partition to the database.
URL Parameters | |
---|---|
format | The format of the data in the request body. Can be
either json , or xml . Use this parameter to override the
Content-type header. |
Upon success, MarkLogic server returns status code 201 (Created). If the payload is malformed or the partition already exists, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.
manage-admin
role, or the following
privilege: http://marklogic.com/xdmp/privileges/manage-admin
Before creating a range partition, you must first define the partition key and set the assignment policy of the database to 'range'. For details, see Configuring a Database with Range Partitions in the Administrator's Guide.
The range
partition configuration in the POST body must contain at least the
partition-name
, lower-bound
, upper-bound
,
forests-per-host
, and host
elements or keys. For more details
and a list of available options, see
tieredstorage:range-partition-create.
Before creating a query partition, you must first set assignment policy for the database to 'query'. For details, see Configuring a Database with Query Partitions in the Administrator's Guide.
The query partition configuration in the POST body must contain
at least the partition-name
, partition-number
,
forests-per-host
, and host
elements or keys. For more details
and a list of available options, see
tieredstorage:query-partition-create.
The structure of the data in the request body is as follows:
partition-name
partition-number
upper-bound
lower-bound
forests-per-host
hosts
This is a complex structure with the following children:
host
replicas
data-directory
large-data-directory
fast-data-directory
options
This is a complex structure with the following children:
option
The following creates a range partition. $ cat range-partition.xml ==> <partition xmlns="http://marklogic.com/manage"> <partition-name>2011</partition-name> <lower-bound>2011-01-01</lower-bound> <upper-bound>2011-12-31</upper-bound> <forests-per-host>1</forests-per-host> <hosts> <host>host-1</host> <host>host-2</host> </hosts> <data-directory></data-directory> <large-data-directory></large-data-directory> <fast-data-directory></fast-data-directory> <options> <option>failover=none</option> </options> </partition> $ curl --anyauth --user user:password -X POST -d @./range-partition.xml \ -i -H "Content-type: application/xml" \ http://localhost:8002/manage/v2/databases/example-db/partitions ==> A new range partition named "2011" is created for example-db. Forests 2011-0001 and 2011-0002 are created, one on each named host. MarkLogic Server responds with headers similar to the following. HTTP/1.1 201 Created Cache-Control: no-cache Expires: -1 Location: /manage/v2/databases/13475778675412262560/partitions/2011 Server: MarkLogic Set-Cookie: SessionID=d647d71d2ffc55d6; path=/ Content-Length: 0 Connection: Keep-Alive Keep-Alive: timeout=5
$ cat range-partition.json ==> { "partition-name": "2012", "lower-bound": "2012-01-01", "upper-bound": "2012-12-31", "forests-per-host": 1, "host": [ "host-1", "host-2" ], "option": [ "failover=none" ] } $ curl --anyauth --user user:passowrd -X POST -d @./range-partition.json \ -i -H "Content-type: application/json" http://localhost:8002/manage/v2/databases/example-db/partitions ==> A new range partition named "2012" is created for example-db. Forests 2012-0001 and 2012-0002 are created, one on each named host. MarkLogic Server responds with headers similar to the following. HTTP/1.1 201 Created Cache-Control: no-cache Expires: -1 Location: /manage/v2/databases/13475778675412262560/partitions/2012 Server: MarkLogic Set-Cookie: SessionID=53f1ed9b18ed7196; path=/ Content-Length: 0 Connection: Keep-Alive Keep-Alive: timeout=5
The following creates a query partition. curl -X POST --anyauth --user admin:admin -H "Content-type: application/json" \ -d '{ "partition-name": "tier1", "partition-number": "1", "forests-per-host": 2, "host": [ "gordon-1.marklogic.com" ], "option": [ "failover=none" ] }' \ http://gordon-1:8002/manage/v2/databases/db1/partitions ==> A new query partition, named "tier1", is created for db1. Forests tier1-0001 and tier1-0002 are created on host, "gordon-1.marklogic.com".
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.